-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BackedEnum attribute typecast behaviour. #20185
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20185 +/- ##
============================================
- Coverage 64.85% 64.84% -0.01%
- Complexity 11409 11411 +2
============================================
Files 431 431
Lines 37142 37146 +4
============================================
Hits 24087 24087
- Misses 13055 13059 +4 ☔ View full report in Codecov by Sentry. |
Any hope for this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks alright overall. Would you please add a line for CHANGELOG? Thanks.
@briedis can you please add a line in the changelog? Seems last thing before merging! |
I added the changelog entry. What do you think about my second commit? Renaming enum cases so they match the suggested formatting (Pascal case) as in PHP's RFC. It may feel weird, but imho it is a better approach, as enums can't be confused with constants. |
I don't see an issue with that. Unless we have something implemented in the other way that can cause inconsistency. I can't think of any so I will leave for anyone who thinks otherwise before merging |
@briedis thanks for your time and efforts! |
@@ -1538,13 +1538,13 @@ public function testBindValuesSupportsEnums() | |||
$db = $this->getConnection(); | |||
$command = $db->createCommand(); | |||
|
|||
$command->setSql('SELECT :p1')->bindValues([':p1' => enums\Status::ACTIVE]); | |||
$command->setSql('SELECT :p1')->bindValues([':p1' => enums\Status::Active]); | |||
$this->assertSame('ACTIVE', $command->params[':p1']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected value should be renamed also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@briedis can you prepare a PR to address this please. @Izumi-kun thanks for spotting and pointing this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. Here's the PR: #20296
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to be sorry. It is OK.
Thanks for PR
Based on the casting approach that Laravel has implemented.
Not sure about validation, I think that should be implemented separately.